package com.netty.cn.model.MoreClient;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.netty.cn.model.MoreClient.client.NettyClient;

import io.netty.channel.ChannelFuture;

/**
 * 
 * @author wangzonghui
 * @date 2021-07-28 10:16:19
 * @Description 启动一个客户端，连接多个服务端
 */
public class OneClient {
	
	public static void main(String[] args) throws InterruptedException {
		
List<Map<String,Object>> portHosts=new ArrayList<>();
		
		Map<String,Object> data=new HashMap<>();
		data.put("IP", "127.0.0.1");
		data.put("PORT", "8080");
		
		portHosts.add(data);
		
		data=new HashMap<>();
		data.put("IP", "127.0.0.1");
		data.put("PORT", "9090");
		
		portHosts.add(data);
		
		Map<String , ChannelFuture> dataList=NettyClient.getChannel(portHosts);
		
		for(ChannelFuture one:dataList.values()) {
			try {
				System.out.println("发送消息");
				NettyClient.sendMsg(one, "nihao");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
